<?php

namespace app\index\controller;

use EasyWeChat\Factory;
use think\App;
use think\Controller;

class Base extends Controller
{
    public  $wxbase;
    public  $wxpay;
    public function __construct(App $app = null)
    {
        parent::__construct($app);
        $this->wxbase = Factory::officialAccount(config('wxconfig'));
        $this->wxpay=Factory::payment(config('wxpayconfig'));

    }
    public function getUserId(){
        if(session('user')){
            $user=session('user');
            if($user['user_openid']=="oyg5cs_Qa1Udbr1f4Uap_wZlTIBM"){
                session(null);
                return $this->error("差不多行了");
            }
            return $user['user_id'];
        }else{
            return null;
        }

    }
    public function isLogin(){
        if(session('user')){
            return true;
        }else{
            return false;
        }
    }
    public function isSaveMsg(){
        $userId=$this->getUserId();
        if(!$userId){
            return false;
        }
        $userMsg=db('user')->find($userId);
        if($userMsg['user_address']){
            return true;
        }else{
            return false;
        }

    }
}
